<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>侦听器-侦听数组元素变化失败</title>
  <script src="vue.js"></script>
</head>
<body>
  <script>
    let vm = new Vue({
      data: {
        array: [0, 1, 2, {x:1}]
      },
      watch: {
        array(newValue) {
          console.log(`array变化为${newValue}`);
        }
      }
    });
    vm.array[2] = 5;     //修改数组元素本身
    vm.array[3].x = 10;  // 数组元素是对象，修改对象的属性
    vm.array.length = 0; //通过length修改数组长度
  </script>
</body>
</html>
